home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1990 / Sep 90 / MacApp.Tech$ 9⁄14⁄90 / 1950-Genericity etc.-Sep90 < prev    next >
Encoding:
Text File  |  1991-03-06  |  5.6 KB  |  107 lines  |  [TEXT/GEOL]

  1. Item    8545306                         8-Sept-90        12:34PDT
  2.  
  3. From:   MADA.EUROPE                     MacApp Dev Assoc Eur,E Carrasco,IDV
  4.  
  5. To:     MACAPP.TECH$                    MacApp Technical
  6.  
  7. Sub:    Genericity etc.
  8.  
  9. Barry, Derek & friends;
  10.  
  11. I have followed the thread on Multiple Inheritance with great interest. I would
  12. rather read this than the Sunday funnies. Really. I download MacApp.Tech$ and
  13. wow, what a way to spend Saturday morning!
  14.  
  15. From what has been able to penetrate the foggy recesses of my mind, it seems to
  16. me that references to uses for MI seem to fall into three broad categories:
  17. 1) We want to subclass from two or more existing libraries the source code of
  18. which we do not have or do not want to tamper with.
  19. 2) We knowingly and willfully create a class hierarchy that is designed to make
  20. efficient use of MI.
  21. 3) We have a design problem and so we use MI as a shortcut.
  22.  
  23. There is not easy way to get around the first need. If you really need both
  24. building blocks, then you need MI, or you will have to write wrapper functions.
  25. Both are legitimate solutions. Which one is ideal would depend on the real
  26. world model we are working with. If you think about it, very few man made
  27. objects are actually the result of multiple inheritance. A seaplane is not an
  28. airplane *and* a boat. It is never used instead of a boat nor is it sold to
  29. someone who needs a boat. It is an airplane that *has* a hull and/or pontoons.
  30. The use of a field to contain an object that has behaviour we wish to add to
  31. our object is *not* an artificial way to avoid MI. It is a valid representation
  32. of reality. Almost everything we own is nothing more than an amalgamation of
  33. other things. Industry uses the word "subassembly" to describe the component
  34. parts of such things. If our objects are very small and only do one thing, and
  35. we combine them into subassemblies, it is true that we may be forced to write
  36. wrapper functions to export their behavior. But it is also true that once a
  37. subassembly is well defined, it may be grafted into another subassembly without
  38. going into contortions and fits of anguish because of a class hierarchy that
  39. was ill conceived.
  40. Besides, I am a little skeptical about inheriting from two different libraries
  41. written independantly. You would inevitably inherit baggage you didn't need.
  42.  
  43. As for the second type of need, where programmers for reasons obscure willfully
  44. and knowingly create MI hierachies, I will abstain from all comment. The
  45. question has been covered by those more apt to shed light on it.
  46.  
  47. The perversity of human nature being what it is, I was not surprised to
  48. discover that nearly all of the cases where I felt I could use MI have finally
  49. proven to belong to the third category, that is the need was perceived but not
  50. real.
  51.  
  52. Which brings me to the focal point of my diatribe.
  53.  
  54. I started writing this link during the week but decided to wait until I
  55. downloaded MacApp.Tech$ before posting it. What joy and disappointment to find
  56. my suggestions posted already! So I'll recapitulate and put in my two cents
  57. worth for the OP++ compiler writers :
  58.  
  59. 1)Genericity: I didn't know until now that it was called genericity. While on
  60. the surface it has absolutely nothing to do with MI, I agree with Barry Wilson
  61. that many temptations to use MI would disappear if I could "patch" an existing
  62. class declaration by inserting my class into an existing hierarchy. Derek, you
  63. said "The ability to slip your own class into someone else's hierarchy may
  64. solve some problems, but could also be very dangerous." I would like to know
  65. why it would be dangerous. It seems like a perfectly benign thing to me. (am I
  66. an innocent and simple minded programmer?) It is definately at the top of my
  67. wish list for OP++. Can you imagine the number of TView improvements that would
  68. crop up overnight if this were possible?
  69. 1b)What are parameterized types?
  70.  
  71. 2) Private Data: Smalltalk data is private. Apple's unofficial C++ guidelines
  72. insist that all data members be declared private. Good OP technique dictates
  73. that data never ever ever be accessed without accessors. Why not make all
  74. fields private and be done with it? I see no use for public data. Even most
  75. globals can safely be dispensed with.
  76. As for the tons of code that will no longer work, the programmers have been
  77. warned for long enough. At worse they'll have to spend a weekend writing SetFoo
  78. and GetFoo methods. Someone may even write a tool that would do it
  79. automatically.
  80. As for the argument that it is useless to write alot of methods that do nothing
  81. but set and get fields, I agree. They should do something useful like range
  82. checking and error signaling.
  83.  
  84. 3) Private methods. I don't see that it would be necessary to redeclare a class
  85. in the IMPLEMENTATION. Besides, it would be a pain. You could just declare the
  86. method like any old procedure, as long as the class name used in the method
  87. declaration was valid. Of course that would not solve the protected problem
  88. which is important if only to acheive a degree of C++ compatability.
  89.  
  90. 4) Functional syntax: I am leery of it. I think INHERITED is better. When I
  91. find myself wanting to call on granddad, I go back over my hierarchy to see
  92. what is wrong. (of course if the hierarchy is not my own, there is nothing I
  93. can do -- unless (1) is implemented)
  94.  
  95. In conclusion, I do not believe that OP must get into a feature war with C++ in
  96. order to survive. Its two main features, simplicity and elegance are out of
  97. reach for C++. If the features described in the preceding links are
  98. implemented, then it will retain a large number of followers even if Apple
  99. Computer Inc. is not among them.
  100.  
  101. Mac 'Appily yours,
  102.  
  103.  
  104. Peter Adamson
  105. MADA.EUROPE
  106.  
  107.